package cahce

import (
	"fmt"
	"github.com/go-redis/redis/v8"
	"golang.org/x/net/context"
	"medical-management-system/appconfig"
)

var ctx = context.Background()
var Rdb *redis.Client

func Init() {
	red := appconfig.AppConf.RedisConfig
	Rdb = redis.NewClient(&redis.Options{
		Addr:     red.Addr,
		Password: red.Password, // no password set
		DB:       red.DB,       // use default DB
	})

	err := Rdb.Set(ctx, "key", "value", 0).Err()
	if err != nil {
		panic(err)
	} else {
		fmt.Println("redis连接成功")
	}
}
